/* Modern CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
}

/* Custom Properties */
:root {
    --primary-color: #009dff;
    --primary-hover: #00ff88;
    --primary-active: #006eb3;
    --primary-dim: rgba(0, 157, 255, 0.1);
    --background-dark: #000000;
    --background-darker: #000000;
    --background-card: #181818;
    --background-hover: #202020;
    --input-bg: #242424;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --text-tertiary: #666666;
    --border-color: #333333;
    --shadow-color: rgba(0, 118, 245, 0.2);
    --error-bg: #2d1215;
    --error-color: #ff4444;
    --success-color: #00ff88;
    --warning-color: #ffd740;
    --transition-speed: 0.3s;
}

/* Base Styles */
body {
    font-family: 'Roboto', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    background-color: var(--background-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* Header and Navigation */
header {
    background-color: var(--background-darker);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Search Input */
#searchInput {
    padding: 0.75rem 1.25rem;
    width: 300px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--transition-speed) ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--shadow-color);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

/* Breadcrumb */
#breadcrumb {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
}

#breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    position: relative;
}

#breadcrumb a:hover {
    color: var(--primary-hover);
}

#breadcrumb a::after {
    content: '/';
    margin-left: 0.5rem;
    color: var(--text-tertiary);
}

#breadcrumb a:last-child::after {
    content: '';
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Card Styles */
.card {
    background: var(--background-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, var(--shadow-color));
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
    background: var(--background-hover);
}

.card:hover::before {
    opacity: 0.1;
}

.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card h2, .card h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
    flex: 1;
}

/* Card Actions Container */
.card-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    flex-wrap: wrap;
}

/* View Button */
.view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #333333;
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    min-width: 120px;
    text-align: center;
    align-self: flex-start;
    pointer-events: auto;
    z-index: 2;
    position: relative;
}

.view-btn:hover {
    background: #444444;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.view-btn:active {
    background: #222222;
    transform: translateY(0);
}

.view-btn i {
    font-size: 1rem;
    margin-right: 8px !important;
    display: inline-block !important;
}

/* Update Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-speed) ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    min-width: 120px;
    text-align: center;
    align-self: flex-start;
    pointer-events: auto;
    z-index: 2;
    position: relative;
}

.download-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.download-btn:active {
    background: var(--primary-active);
    transform: translateY(0);
}

.download-btn i {
    font-size: 1rem;
    margin-right: 8px !important;
    display: inline-block !important;
}

/* Error States */
.error {
    color: var(--error-color);
    padding: 1rem 1.5rem;
    background: var(--error-bg);
    border-radius: 8px;
    border-left: 4px solid var(--error-color);
    margin-bottom: 1.5rem;
}

/* Loading States */
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--text-primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Search Results Styling */
.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.result-count {
    font-size: 1.2rem;
    color: var(--text-secondary);
    padding: 8px 16px;
    background-color: rgba(0, 157, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 3px solid var(--primary-color);
}

.search-result {
    display: flex;
    flex-direction: column;
}

.search-result .card-content {
    flex: 1;
}

.search-result h3 {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin-bottom: 10px;
}

.search-result .description {
    color: var(--text-primary);
    margin-bottom: 15px;
    line-height: 1.6;
}

.search-result .metadata {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.search-result .card-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Layout */
/* Large screens (desktop) - 3 cards per row */
@media (min-width: 1201px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* Medium screens (tablet) - 2 cards per row */
@media (max-width: 1200px) and (min-width: 901px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Smaller tablets and large phones */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px;
    }
    
    .card {
        padding: 1.25rem;
    }
    
    .card h2, .card h3 {
        font-size: 1.1rem;
    }
    
    .card p {
        font-size: 0.9rem;
    }
    
    /* Nav adjustments */
    .nav-container {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .menu-button {
        display: block;
    }
    
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: 1rem 0;
        order: 3;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-link {
        width: 100%;
        justify-content: center;
    }

    #searchInput {
        width: 100%;
        order: 2;
    }
    
    /* Hide navigation line in mobile view */
    nav::after {
        display: none !important;
    }
}

/* Medium phones */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 16px;
    }
    
    .card {
        padding: 1.5rem;
        /* Don't change to horizontal layout */
        flex-direction: column;
    }
    
    .card h2, .card h3 {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }
    
    .card p {
        font-size: 1rem;
        margin-bottom: 1.2rem;
        /* Show full text, not truncated */
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: visible;
    }
    
    .download-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        align-self: flex-start;
        margin-top: 0.5rem;
        width: auto;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 12px;
    }
    
    .card {
        padding: 1.25rem;
        /* Maintain vertical layout */
        flex-direction: column;
    }
    
    .card-content {
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    .card h3 {
        font-size: 1.25rem;
        margin-bottom: 0.7rem;
    }
    
    .card p {
        font-size: 0.95rem;
        margin-bottom: 1rem;
        /* Show full text, not truncated */
        display: block;
        -webkit-line-clamp: unset;
        -webkit-box-orient: unset;
        overflow: visible;
    }
    
    .download-btn {
        margin-left: 0;
        padding: 0.75rem 1.25rem;
        width: 100%;
        font-size: 0.95rem;
        align-self: stretch;
    }
    
    .card-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .view-btn, .download-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Extra small phones */
@media (max-width: 360px) {
    .grid {
        gap: 12px;
        padding: 10px;
    }
    
    .card {
        padding: 1.1rem;
    }
    
    .card h3 {
        font-size: 1.15rem;
    }
    
    .card p {
        font-size: 0.9rem;
    }
    
    .download-btn {
        padding: 0.7rem 1.1rem;
        font-size: 0.9rem;
    }
}

/* Custom Scrollbar - Make it smaller and minimal */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.02);
}

/* Focus Styles */
:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--shadow-color);
}

/* Selection Styles */
::selection {
    background: var(--primary-color);
    color: var(--text-primary);
}

/* Footer Section */
.footer {
    position: relative;
    background-color: var(--background-darker);
    color: var(--text-primary);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: 4rem;
    border-top: 2px solid var(--primary-color);
    position: relative;
    overflow: hidden;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    animation: borderGlow 3s linear infinite;
}

@keyframes borderGlow {
    0% { left: -100%; }
    100% { left: 100%; }
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 2rem;
}

.footer-section h3 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 15px;
    position: relative;
    display: inline-block;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background-color: var(--primary-color);
}

.footer-section p {
    margin: 10px 0;
    transition: transform 0.3s ease;
    line-height: 1.6;
}

.footer-section p:hover {
    transform: translateY(-2px);
}

.tagline {
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section ul li a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    padding-left: 15px;
}

.footer-section ul li a::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.footer-section ul li a:hover {
    color: var(--text-primary);
    padding-left: 20px;
}

.footer-section ul li a:hover::before {
    transform: translateX(3px);
}

.feedback-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid var(--primary-color);
    transition: all 0.3s ease;
    background: transparent;
    position: relative;
    overflow: hidden;
    margin-top: 10px;
}

.feedback-link:hover {
    color: var(--text-primary);
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.feedback-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.feedback-link:active::before {
    width: 200px;
    height: 200px;
}

.footer-bottom {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(160, 160, 160, 0.2);
}

.developer-name {
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.developer-name:hover {
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-dim);
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.social-link:hover {
    background-color: var(--primary-color);
    color: var(--text-primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 10px var(--shadow-color);
}

/* Better mobile footer */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 1rem 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .footer-section {
        width: 100%;
    }
    
    .footer-section h3 {
        font-size: 1.2rem;
    }
    
    .footer-section ul li {
        margin-bottom: 12px;
    }
    
    .footer-section ul li a {
        font-size: 1rem;
    }
    
    .social-links {
        margin-top: 20px;
    }
    
    .social-link {
        width: 44px;
        height: 44px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .footer::before {
        animation: none;
    }
    
    .footer-section p:hover,
    .feedback-link:hover,
    .footer-section ul li a:hover,
    .footer-section ul li a:hover::before,
    .social-link:hover,
    .card:hover {
        transform: none;
    }
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    /* Ensure menu button is visible */
    .mobile-menu-button {
        display: flex !important;
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1000;
        background-color: var(--primary-color);
        color: white;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 14px;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        border: 1px solid rgba(255,255,255,0.1);
    }
    
    .mobile-menu-button i {
        margin-right: 6px;
    }
    
    /* Reduce container size */
    .container {
        width: 94%;
        padding: 15px;
        margin: 10px auto;
    }
    
    .card {
        padding: 15px;
        margin-bottom: 15px;
    }
}

/* Smaller screens */
@media screen and (max-width: 480px) {
    .container {
        width: 92%;
        padding: 12px;
    }
    
    .card {
        padding: 12px;
    }
}

/* Mobile styles for the download-btn and view-btn */
@media (max-width: 480px) {
    .card-actions {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .view-btn, .download-btn {
        width: 100%;
        justify-content: center;
        min-width: unset;
        padding: 0.75rem 1rem;
    }
}

/* Materials container and cards */
.materials-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Material card styles - not clickable */
.material-card {
    cursor: default !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

.material-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: var(--primary-color);
}

.card-header {
    margin-bottom: 1rem;
}

.meta-label {
    font-weight: 500;
    color: var(--text-secondary);
}

/* Touch-friendly card styles for mobile */
@media (max-width: 768px) {
    .material-card {
        pointer-events: auto !important;
    }
    
    .material-card .card-actions {
        pointer-events: auto;
        position: relative;
        z-index: 10;
    }
    
    .material-card a {
        padding: 12px !important; /* Larger touch targets */
    }
}